﻿#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include "igbtprotocol.h"
#include "qcustomplot.h"
#include "globalsettings.h"

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

private:
    Ui::MainWindow *ui;
    QCPCurve* _hchannelCurve[GlobalSettings::SAMPLE_HCHANNEL_SUM];
    QCPCurve* _lchannelCurve[GlobalSettings::SAMPLE_LCHANNEL_SUM];

protected:
    void initUI();
    void initHCurve();
    void initLCurve();

    void logOut(QtMsgType type, const QString msg);
    void depackHChannelSampleData(IGBTProtocol::DataFrame* dataFrame);
    void depackLChannelSampleData(IGBTProtocol::DataFrame* dataFrame);
    void clearPlot();
    void updateHChannelPlot(/*int channelSampleNum = -1*/);
    void updateLChannelPlot(/*int channelSampleNum = -1*/);

public slots:
    void stateChanged(unsigned int state, int err, int extra);
    void ackReady(void* frame);

    void on_hCh1CheckBox_stateChanged(int state);
    void on_hCh2CheckBox_stateChanged(int state);
    void on_hCh3CheckBox_stateChanged(int state);
    void on_hCh4CheckBox_stateChanged(int state);
    void on_hCh5CheckBox_stateChanged(int state);
    void on_hCh6CheckBox_stateChanged(int state);
    void on_hCh7CheckBox_stateChanged(int state);
    void on_hCh8CheckBox_stateChanged(int state);

    void on_lCh1CheckBox_stateChanged(int state);
    void on_lCh2CheckBox_stateChanged(int state);
    void on_lCh3CheckBox_stateChanged(int state);
    void on_lCh4CheckBox_stateChanged(int state);
    void on_lCh5CheckBox_stateChanged(int state);
    void on_lCh6CheckBox_stateChanged(int state);
    void on_lCh7CheckBox_stateChanged(int state);
    void on_lCh8CheckBox_stateChanged(int state);
    void on_lCh9CheckBox_stateChanged(int state);
    void on_lCh10CheckBox_stateChanged(int state);
    void on_lCh11CheckBox_stateChanged(int state);
    void on_lCh12CheckBox_stateChanged(int state);
    void on_lCh13CheckBox_stateChanged(int state);
    void on_lCh14CheckBox_stateChanged(int state);
    void on_lCh15CheckBox_stateChanged(int state);
    void on_lCh16CheckBox_stateChanged(int state);

    void on_devInterfaceAction_triggered();
    void on_devConnectAction_triggered();
    void on_devDisconnAction_triggered();

    void on_singleOpenCapAction_triggered();
    void on_singleShutupCapAction_triggered();
    void on_replayCapAction_triggered();
    void on_stopCapAction_triggered();
};

#endif // MAINWINDOW_H
